

  <div style="margin:1% 5%;">
    <div class="layui-form-item" style=";padding-left: 30%;">

      <div class="layui-input-inline">
        <input type="text" id="macfjval" placeholder="请输入房间号/mac地址/ip" autocomplete="off" class="layui-input">

      </div>
      <label class="layui-form-label" style="padding: 0!important;"><button type="button" class="layui-btn" id="btnSearch" lay-event="shousuo">搜索</button></label>
    </div>
  </div>

  <!--<div id="demo1"></div>-->
</div>
  <div style="padding-left: 50px;display: none">
    <caption style="margin-left: 40px;"><span >
                <button type="button" class="btn btn-primary layui-btn"  onclick="method5('tableExcel')">
                    <span class="glyphicon glyphicon-folder-open">导出Excel</span>
                </button>
            </span>
    </caption>
  </div>
<script type="text/html" id="tol">
  <div>
    <div style="float:left;">解绑列表</div>
    <div style="float:right;margin-right: 50px">共有数据：<span id="count"></span>条</div>
  </div>

</script>


  <script type="text/html" id="jieban">
    <input type="button" value="解绑" class="layui-btn layui-btn-xs" lay-event="btnJieban"/>
  </script>

<table class="layui-table" id="data2" lay-filter="data2">

</table>

<script>

  var local_store = layui.data("local_store");
  var local = local_store.token;
  $.ajax({
    type:"get",
    url:"/admin/station/query/stationLoginQuanxXian?stationId="+json.id,
    dataType: "json",
    contentType:"application/json;charset=utf-8",
    beforeSend: function(request) {
      request.setRequestHeader("token", local);
    },
    success:function (res) {
      if(res.code==500){
        alert("权限不足")
        location="../../admin/main.html";
        return
      }}})
  function GetRequest() {
    var url = decodeURI(location.search); //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {
        theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
      }
    }
    return theRequest;
  }

  var pages= localStorage.getItem('page');
  var json=GetRequest();
  layui.use('table', function(){
    var table = layui.table;

    table.render({
      elem: '#data2'
      ,  id: "t"
      ,  toolbar:"#tol"
      , method: 'post'
      ,url:'/admin/terminal/queryIpMacFjAll?terminalStation='+json.id+"&terminalShenhe=未审核"
      ,cols: [[
        {field:'terminal_id', title: '终端编号',
          align: "center"}
        ,{field:'terminal_ip', title: 'IP地址',
          align: "center"}
        ,{field:'terminal_mac',
          align: "center", title: 'MAC地址'}
        ,{field:'terminal_key',
          align: "center",  title: '密码'}
        ,{field:'station_bh', title: '站点编号',
          align: "center"} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
        ,{field:'terminal_room',
          align: "center", title: '房间号'}
        ,{field:'terminal_line',
          align: "center",  title: '是否在线'}
        ,{field:'group_name',
          align: "center", title: '所属分组'}
        ,{field:'terminal_version_code',
          align: "center", title:'版本'}
        ,{field:'terminal_system_model',
          align: "center", title: '型号'}
        , {
          title: '操作',
          align: 'center',
          width:'',
          toolbar: '#jieban',
          width: '20%',
          fixed: 'right'
        }

      ]],page:true,
      limit:40,
      done: function(res, curr, count){
        localStorage.setItem('page',curr);
        $("#count").html(count);
      }
    });

    $("#btnSearch").click(function(){
      table.reload("t",{
        where:{
          macfj:$("#macfjval").val()
        },
        page:{
          curr:1
        }
      });
    });
  });


  //    右侧按钮的的监听事件
  table.on('tool(t)', function (obj) {
    var getdata = obj.data //获得当前行数据
    var layEvent = obj.event //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
    var tr = obj.tr //获得当前行 tr 的 DOM 对象（如果有的话）
    switch (layEvent) {
        case "btnJieban":
          var close = layer.confirm("确定审核?", {
            title: "提示",
            btn: ["同意", "不同意"],
            btn1: function () {
              $.ajax({
                type: "get",
                url: "/admin/terminal/editterminalShenhe",
                async: true,
                data: {
                  terminalId: getdata.terminal_id,
                  terminalStation:getdata.station_bh

                },
                success: function (res) {
                  //if (res.code == 200)
                  {
                    $(tr).remove();
                    layer.close(close);
                    layer.msg("审核完成", {
                      icon: 1
                    });
                    tr.find(":button:last").remove();
                    return;
                  }

                  /* layer.msg('审核失败', {
                       icon: 2
                   });*/
                }
              })
            },
            btn2: function () {
              $.ajax({
                type: "get",
                url: "/admin/terminal/editterminalShenhe2",
                async: true,
                data: {
                  terminalId: getdata.terminal_id

                },
                success: function (res) {
                  if (res.code == 200) {
                    $(tr).remove();
                    layer.close(close);
                    layer.msg("审核完成", {
                      icon: 1
                    });
                    tr.find(":button:last").remove();
                    return;
                  }

                  layer.msg('修改失败', {
                    icon: 2
                  });
                }
              })
            }

          });

    }
  });

</script>
